import pymysql
conn = pymysql.connect(
    host='localhost',
    port=3306,
    user='root',
    passwd='3326',
    db='assisant',
    charset='utf8',
    cursorclass=pymysql.cursors.DictCursor
)
def query_user_no_exists(username):
    sql = 'select * from sys_user where user_name = %s'
    cur = conn.cursor()
    cur.execute(sql, [username])
    result = cur.fetchone()
    if result is None:
        return True
    else:
        return False
def add_user(username, password):
    sql = 'insert into sys_user (user_name, pass) values (%s, %s)'
    cur = conn.cursor()
    cur.execute(sql, [username, password])
    conn.commit()

def query_user_pass(username):
    sql = 'select * from sys_user where user_name = %s'
    cur = conn.cursor()
    cur.execute(sql, [username])
    result = cur.fetchone()
    passwd = result['pass']
    return passwd